<include file="public:header"/>
<include file="public:sidebar"/>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            商户提现审核
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">提现</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="col-md-12">
            <div style="margin: 10px;">
                <button onclick="history.go(-1)" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-danger">
                    <i class="layui-icon">&#xe65c;</i>返回
                </button>
            </div>
            <!-- Horizontal Form -->
            <div class="box box-info">
                <div class="box-header with-border">
                    <h3 class="box-title">提现</h3>
                </div>
                <!-- /.box-header -->
                <!-- form start -->
                <form action="{:Url('mch/update_withdraw')}" method="post"
                      class="form-horizontal layui-form" autocomplete="off">
                    <div class="box-body">
                        <notempty name="info">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">
                                    申请名称
                                </label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control"
                                           placeholder="申请名称" name="name"
                                           lay-verify="required"
                                           readonly
                                           value="<notempty name='info'>{$info.name}</notempty>">
                                    <input type="hidden" name="id"
                                           value="<notempty name='info'>{$info.id}</notempty>">
                                    <input type="hidden" name="status" value="2">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">
                                    申请金额
                                </label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control"
                                           name="tel"
                                           readonly
                                           placeholder="申请金额"
                                           value="<notempty name='info'>{$info.money}</notempty>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">
                                    申请时间
                                </label>
                                <div class="col-sm-4">
                                    <notempty name='info'>
                                        <input readonly type="text" class="form-control"
                                               value="{$info.create_time}" id="test1">
                                    </notempty>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">
                                    <empty name='info'>是否通过<else/>状态</empty>
                                </label>
                                <div class="col-sm-10">
                                    <empty name='info'>
                                        <div class="radio">
                                            <label>
                                                <input type="radio" <empty name='info'>checked<else/><eq name="info.status" value="2">checked</eq></empty> name="status" value="2">是
                                            </label>
                                            <label>
                                                <input type="radio" <notempty name="info"><eq name="info.status" value="3">checked</eq></notempty> name="status" value="3">否
                                            </label>
                                        </div>
                                        <else />
                                        <p style="margin-top: 10px;">
                                            <eq name="info.status" value="1">申请中</eq>
                                            <eq name="info.status" value="2">通过</eq>
                                            <eq name="info.status" value="3">拒绝</eq>
                                        </p>
                                    </empty>
                                </div>
                            </div>
                            <if condition="$info['status'] eq 1">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        操作
                                    </label>
                                    <div class="col-sm-4">
                                        <input type="checkbox" class="cross"
                                               lay-skin="switch"
                                               lay-text="通过|拒绝"  lay-filter="cross" checked>
                                        <div class="clearfix"></div>
                                        <textarea name="info" placeholder="请输入拒绝理由"
                                                  class="layui-textarea" style="margin-top: 10px;display: none;"></textarea>
                                    </div>
                                </div>
                            </if>
                            <else />
                            <div class="form-group">
                                <label class="col-sm-2 control-label">
                                    可提现余额
                                </label>
                                <div class="col-sm-4">
                                    <input type="text" readonly class="form-control"
                                           placeholder="可提现余额" name="name"
                                           lay-verify="required"
                                           value="<notempty name='mch'>{$mch.money}</notempty>">
                                    <input type="hidden" name="mc_id"
                                           value="<notempty name='mch'>{$mch.id}</notempty>">
                                    <input type="hidden" name="status" value="2">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">
                                    提现金额
                                </label>
                                <div class="col-sm-4">
                                    <input type="hidden" name="id" value="0">
                                    <input type="text" class="form-control"
                                       name="money"
                                       lay-verify="money"
                                       placeholder="申请金额"
                                        value="">
                                </div>
                            </div>
                        </notempty>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">
                            </label>
                            <div class="col-sm-4">
                                <button type="submit" class="btn btn-info" lay-submit lay-filter="*">确定</button>
                                <!--<button type="reset" class="btn btn-default">取消</button>-->
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </section>
    <!-- /.content -->
</div>
<script>
    layui.use(['form','layer'],function () {
        var form = layui.form,
            layer = layui.layer;
        form.on('switch(cross)', function(data){
            if(data.elem.checked){
                $('textarea[name="info"]').val('').hide();
                $('input[name="status"]').val(2);
            }else {
                $('textarea[name="info"]').val('').show();
                $('input[name="status"]').val(3)
            }
        });
        form.verify({
            money: function(value, item){
                if(!value){
                    return '请填写金额';
                }
                if(value < 1 || value > 1000){
                    return '金额必须介于0.1到1000元之间';
                }
                if(value > Number('{$mch.money}')){
                    return '提现金额超出最大额度';
                }
            }
        });
        form.on('submit(*)', function(data){
            var index = layer.load(2,{shade: [0.8, '#000']});
            $.post(data.form.action,data.field,function (result) {
                layer.close(index);
                if(result.code){
                    layer.msg(result.msg);
                    return false;
                }
                layer.alert(result.msg,{icon:6,end:function () {
                    location.href = result.data.redirect;
                }});
            });
            return false;
        });
    });
    function init(){
        var data = $('form').serialize();
        layui.use(['laytpl','layer'],function () {
            var laytpl = layui.laytpl,
                layer = layui.layer;
            var index = layer.load(2,{shade: [0.8, '#000']});
            $.post(url,data,function (result) {
                layer.close(index);
                if(result.code === 0){
                    var getTpl = demo.innerHTML;
                    laytpl(getTpl).render(result.data, function(html){
                        $('table>tbody').html(html);
                        $('#pages').val(result.data.current_page);
                    });
                }
            });
        });
    }
</script>
<include file="public:footer"/>